package thinkingJava.chapter13;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Groups {
	public static final String POEM =
		"Twas bliding,and the slithy toves\n" +
		"Div jyre and jimble in the wabe.\n" +
		"All mimsy were the borogoves,\n" +
		"And the more raths outgrade.\n\n" +
		"Beware the Jabberwock,my son,\n" +
		"The jaws that bites,the claws thar catch,\n" +
		"Beware the Jabjab bird,and shun\n" +
		"The frumious Bandersnatch.";
	public static void main(String[] args) {
		Matcher m = Pattern.compile("(?m)(\\S+)\\s+((\\S+)\\s+(\\S+))$")
			.matcher(POEM);
		while (m.find()) {
			for (int i = 0; i < m.groupCount(); i ++) {
				System.out.println("[" + m.group(i) + "]");
				System.out.println();
			}
		}
	}
}
